package form;

import java.awt.BorderLayout;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
//import javax.swing.event.HyperlinkEvent;


public class InstructionBox extends JFrame {
	
	public InstructionBox()
	{
		setTitle("Instructions");
		setSize(460,520);
		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		createContents();
		setVisible(true);
	}
    
    private void createContents()
    {
    	setResizable(false);
        setLayout(new BorderLayout());
        JTextArea text_area = new JTextArea(getInstructions());
        JScrollPane scroll_pane = new JScrollPane(text_area);
        
    	text_area.setEditable(false);
    	text_area.setLineWrap(true);
    	text_area.setWrapStyleWord(true);
    	add(scroll_pane,BorderLayout.CENTER);
    }
    
    private String getInstructions()
    {
    	Scanner fileIn;
    	String txtInstructions="";
    	String line;
    	String fileName="src/resources/instructions.txt";
    	//String fileName="src/resources/test.txt";
    	
    	try {
    		fileIn = new Scanner(new FileReader(fileName));
    		while (fileIn.hasNextLine())
    		{
    			line = fileIn.nextLine();
    			if (line.equalsIgnoreCase(""))
    				txtInstructions += "\n\n";
    			else 	
    				txtInstructions += line;
    		}
    		fileIn.close();
    	} catch (FileNotFoundException e) 	{
    		txtInstructions="file not found";
    	}

    	return txtInstructions;
    }

    
    public static void main(String args[]) {
        new InstructionBox();
    }
}
